/* ==============================================================================
 * 创 建 者：LYT
 * 创建日期：2018-03-14	
 * 功能描述：

 * 修 改 人:
 * 修改时间:
 * 修改描述：
 * ==============================================================================*/

//获取订单信息
var getOrderWaitingPayInfoUrl = baseUrl + 'MallF/PayOrder';
//订单支付
var OrderPayUrl = baseUrl + 'MallF/PayOrderMoney';



var vu;
var oid = getURLParameter("oid");

$(function(){
	muiInit();
	initVue();
	Vue.nextTick(function(){
		vu.oid = oid;
		bindEvent();
	})
})

function initVue(){
	vu=new Vue({
		el:'#content',
		data:{
			oid : '',
			orderInfo : '',
			OrderCode : '',
			coin : [],
			buyType : '',
			OrderCash : '',
		},
		mounted: function() {
			this.getOrderWaitingPayInfo();
		},
		methods:{
			getOrderWaitingPayInfo : getOrderWaitingPayInfo,
			OrderPay : OrderPay,
		}
	})
}

function OrderPay(){
//	vu.buyType = $("input[name=buyType]:checked").val();
//	vu.buyType = vu.coin.GoldOID;
	/*if(!vu.buyType){
		mui.toast('请选择支付币种！');
		return;
	}*/
	var btnArray = ['取消', '确定'];
	mui.prompt('', '', '请输入安全密码：', btnArray, function(e) {
		if(!e.value){
			mui.toast('请输入安全密码！');
			return;
		}
        if (e.index == 1) {
            common.post(OrderPayUrl,{OID : vu.oid ,SecondPassword : e.value},'json',function(r){//, buyType : vu.buyType
				if(r.ErrorCode==0){
					location.href = 'finishedBuy.html?oid=' + vu.orderInfo.Order.OrderCode;
				}else{
					mui.toast(r.ErrorMsg);
				}
			})
        } else {
            
        }
    },'div')
	document.querySelector('.mui-popup-input input').type='password';
	
}

function getOrderWaitingPayInfo(){
	common.get(getOrderWaitingPayInfoUrl,{OID : oid},'json',function(r){
		if(r.ErrorCode==0){
			vu.orderInfo = r.Data;
			vu.OrderCode = r.Data.Order.OrderCode;
			vu.OrderCash = r.Data.Order.OrderCash;
			if(r.Data.Order.PayList.PayModelList.length){
				vu.coin = r.Data.Order.PayList.PayModelList;
			}
		}else{
			mui.toast(r.ErrorMsg);
		}
	})
}


function muiInit(){
	mui.init();
	//修改弹出框默认input类型为password
//	document.querySelector('.mui-popup-input input').type='password' 
}

function bindEvent(){
	$("nav").on("tap", "a", function() { //点击触发  
		location.href = $(this).attr("href");
	})
}
